-
Notifications
You must be signed in to change notification settings - Fork 6
refactor: make PowerGridModelInterface._setup_model a public method #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Thijs Baaijen <[email protected]>
|
vincentkoppen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, would be nice to have some tests since it is now a public method.
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]> # Conflicts: # tests/integration/loadflow/test_power_grid_model.py
Signed-off-by: Thijs Baaijen <[email protected]>
Signed-off-by: Thijs Baaijen <[email protected]>
…blic # Conflicts: # tests/integration/loadflow/conftest.py # tests/integration/loadflow/test_power_grid_model.py
Signed-off-by: Thijs Baaijen <[email protected]>
…nto feat/setup-model-public # Conflicts: # src/power_grid_model_ds/_core/load_flow.py
Signed-off-by: Thijs Baaijen <[email protected]>
jaapschoutenalliander
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is fine, I do wonder what use case you have for making the method public?
# Conflicts: # tests/integration/loadflow/test_power_grid_model.py
|
Mostly to keep the code readable. def get_high_and_low_power_flow_results(grid) -> dict[str, dict]:
pgm = _setup_pgm_model(grid) # uses .setup_model()
pgm_output = {}
for peak_load in [PeakLoad.HIGH, PeakLoad.LOW]:
sources = get_sources(grid, peak_load)
sym_loads = get_loads_per_component(grid, peak_load)
pgm_output[peak_load] = _calculate_power_flow(pgm, sym_loads, source)
)
return pgm_output
def _calculate_power_flow(pgm: PowerGridModelInterface, sym_loads: np.ndarray, source: SourceArray) -> dict[str, np.ndarray]:
pgm.update_model(update_data={"sym_load": _get_sym_load_updates(sym_loads)})
pgm.update_model(update_data={"source": _get_source_updates(source)})
pgm.calculate_power_flow(calculation_method=CalculationMethod.linear)
return copy(pgm.output_data) |



See title.